Yes-no Combinators and an Eecient Abstraction Algorithm

نویسنده

  • Antoni Diller
چکیده

ion: [x] P1 P2 : : : Pm = t1t2 : : : tm Q1 Q2 : : : Qm; where, for 1 i m and m 1, ti = y and Qi = [x] Pi, if x 2 FV (Pi); and ti = n and Qi = Pi, if x 62 FV (Pi). Reduction: t1t2 : : : tm P1 P2 : : : Pm Pm+1 ! Q1 Q2 : : : Qm; where, for 1 i m and m 1, Qi = Pi, if ti = n; and Qi = Pi Pm+1, if ti = y. Figure 4: Abstraction and reduction schemas for m-place yes-no combinators. call J. The abstraction rule displayed in Fig. 4 is not, however, su cient by itself to form a bracket abstraction algorithm because it behaves strangely when m = 1. Then, we have: [x] P1 = n P1; if x 62 FV (P1); [x] P1 = y ([x] P1); if x 2 FV (P1): The yes-no combinator n isK and y is I(1), but the abstraction clause leads to an in nite regress (non-termination) when x 2 FV (P1). For this reason I propose the slightly inelegant algorithm shown in Fig. 5. When applying algorithm (Y) it should be remembered that every term P can be expressed in the form P1 P2 : : : Pm, where P1 is an atom (known as the head of P ), and that such a representation is unique. Thus, when applying clause (y) it will always be assumed that P1 is an atom. In fact, when arbitrary terms are discussed from now on and shown as P1 P2 : : : Pm it will be assumed that P1 is an atom. Some examples of the application of algorithm (Y) should make its operation clear: [x] x y (y z x) z = ynyn ([x] x) y ([x] y z x) z = ynyn I y (y z) z: Note that the result is not yyn (yn I y) (y z) z because when applying the algorithm to a term P = P1 P2 : : : Pm we always use that representation in which P1 is an atom. If we now abstract y from ynyn I y (y z) z we obtain nnyyn ynyn I I (yn I z) z. We also have that: [z][y][x] x y (y z x) z = nnnnyy nnyyn ynyn I I (yn I) I: It may be of interest to the reader to compare these with what happens when 6 [x] x = I; (b) [x] E x = E; (c) [x] P1 P2 : : : Pm = t1t2 : : : tm Q1 Q2 : : : Qm; (y) [x] E = K E; (a) where m 2, P1 is an atom and for 1 i m, ti = y and Qi = [x] Pi, if x 2 FV (Pi); and ti = n and Qi = Pi, if x 62 FV (Pi). Figure 5: Algorithm (Y). we apply algorithm (C) to the same terms: [x] x y (y z x) z = C (S (C I y) (y z)) z; [y][x] x y (y z x) z = C0 C (S0 S (C I) (C I z)) z; [z][y][x] x y (y z x) z = S0 (C0 C) (B0 (S0 S) (C I) (C I)) I: The lengths of the terms produced by algorithm (Y) are 6, 8 and 8, whereas those produced by (C) are 8, 10 and 11, respectively. Note also that the result of applying (Y) usually consist of a string of yes-no combinators. It may be possible to devise a calculus which combines such strings into a single combinator, rather like the fact that allows us to replace an initial combination B B in a term by B0. 4 The Complexity of Algorithm (Y) The complexity of algorithm (Y) is particularly easy to work out. Let #R be the number of atoms in the term R. Then, for n 1, if #R = n, then #([x] R) 2n. This is straightforwardly proved using induction on the number of atoms in R. The proof uses a slight variant of what is sometimes called the general principle of induction (Stewart and Tall, 1977, p. 162). This states that a property (n) holds for all positive integers n if it holds for (1) and if it holds for (n+ 1) on the assumption that it holds for all (i) where 1 i n. Proof: When #R = 1, then R is either the same as the abstraction variable or it is not. In the former case [x] x = I and #([x] x) = 1. In the second case [x] R = K R and #([x] R) = 2. In both cases #([x] R) 2 = 2 #R. Let #R = n 2. Every term R can be expressed in the form P1 P2 : : : Pm, where P1 is an atom. There are two cases to consider. In the rst we have that Pm = x and x 62 FV (P1 P2 : : : Pm 1). In this case: [x] R = [x] P1 P2 : : : Pm 1 x; = P1 P2 : : : Pm 1; 7 by clause (c). Thus, #([x] R) = n 1 and what we are trying to prove holds.In the second case we assume that either Pm 6= x or x 2 FV (P1 P2 : : : Pm 1).Thus,[x] R = [x] P1 P2 : : : Pm;= b Q1 Q2 : : : Qm;where b is some yes-no combinator and for 1 i m, Qi = [x] Pi, if x 2FV (Pi); and Qi = Pi, if x 62 FV (Pi). Then,#([x] R) = 1 + #Q1 + #Q2 + +#Qm;= 1 + 1+ #Q2 + + #Qm;as #Q1 = 1 in all cases. If P1 = x, then Q1 = I. If P1 6= x, then Q1 = P1, whereP1 is an atom distinct from x. By the inductive hypotheses, #Qi 2 #Pi,for 2 i m. Thus,#([x] R) 2 + 2 #P2 + + 2 #Pm;= 2 + 2 (#P2 + +#Pm);= 2 + 2 (#R 1) = 2 #R;as #P2 + +#Pm = #R 1. Thus the result is proved. QED.5 ConclusionMany abstraction algorithms have been published in the research literature andsome of these are very e cient. For example, Noshita and Hikita (1985) pro-duce an algorithm where #([x] R) 3 #R and Piperno (1987) describes analgorithm which is such that #([x] R) 5n=2 3, where n = #R (p. 49). Thealgorithm of Castan, Durand and Lemâ tre (1987) has a space complexity com-parable to that of algorithm (Y). The abstraction process of (Y) is, however,simpler than that of any of the other algorithms mentioned.There are similarities between the yes-no combinators introduced in thispaper and the directors of (Kennaway and Sleep, 1987), on the one hand, and theiconic combinators of (Stevens, 1993), on the other. A more detailed comparisonwill be the subject of a future paper.AcknowledgementsI am grateful to David Stevens for helpful comments on an earlier draft of thispaper.8 ReferencesBunder, M. W. (1990). Some improvements to Turner's algorithm for bracketabstraction, The Journal of Symbolic Logic 55: 656{669.Castan, M., Durand, M.-H. and Lemâ tre, M. (1987). A set of combinators forabstraction in linear space, Information Processing Letters 24: 183{188.Curry, H. B. and Feys, R. (1958). Combinatory Logic, Vol. 1, North-Holland,Amsterdam.Diller, A. (1988). Compiling Functional Languages, Wiley, Chichester.Hindley, J. R. and Seldin, J. P. (1986). Introduction to Combinators and -calculus, Cambridge University Press, Cambridge. London MathematicalSociety Student Texts, vol. 1.Joy, M. S., Rayward-Smith, V. J. and Burton, F. W. (1985). E cient combinatorcode, Computer Languages 10: 211{224.Kennaway, J. R. and Sleep, M. R. (1987). Variable abstraction in O(n logn)space, Information Processing Letters 24: 343{349.Noshita, K. and Hikita, T. (1985). The BC-chain method for representingcombinators in linear space, New Generation Computing 3: 131{144.Piperno, A. (1987). A compositive abstraction algorithm for combinatory logic,in H. Ehrig, R. Kowalski, G. Levi and U. Montanari (eds), TAPSOFT '87,Vol. 250 of Lecture Notes in Computer Science, Springer-Verlag, Berlin,pp. 39{51.Stevens, D. (1993). Variable substitution with iconic combinators. Paper pre-sented at the 18th International Symposium on the Mathematical Founda-tions of Computer Science held in Gda nsk, Poland, and to be published inthe proceedings by Springer-Verlag.Stewart, I. and Tall, D. (1977). The Foundations of Mathematics, Oxford Uni-versity Press, Oxford.Turner, D. A. (1979a). Another algorithm for bracket abstraction, The Journalof Symbolic Logic 44: 267{270.Turner, D. A. (1979b). A new implementation technique for applicative lan-guages, Software|Practice and Experience 9: 31{49.9

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Investigations into Iconic Representations of Combinators

Various properties of two bracket abstraction algorithms, previously introduced, are discussed and some of them are proved in this paper. Algorithm (L) is uni-variate and uses yes-no representations, whereas algorithm (M) is multi-variate and uses array representations. It is shown that (a) both algorithms are structure-preserving, (b) there is a straightforward connection between [x] P and [x]...

متن کامل

Making Abstraction Behave by Rerepresenting Combinators

When bracket abstraction is being used to implement a functional programming language, it is desirable, according to Turner, that the algorithm used produces short abstracts, uses only a finite number of combinators, is uni-variate and also well-behaved under self-composition. In this paper I show that it is impossible to devise an algorithm using a finite number of combinators that is always w...

متن کامل

Expedited Broda-Damas Bracket Abstraction

A bracket abstraction algorithm is a means of translating λ-terms into combinators. Broda and Damas, in [1], introduce a new, rather natural set of combinators and a new form of bracket abstraction which introduces at most one combinator for each λ-abstraction. This leads to particularly compact combinatory terms. A disadvantage of their abstraction process is that it includes the whole Schonfi...

متن کامل

Bracket Abstraction in the Combinator System C`(k)

Translations from lambda calculi to combinatory logics can be used to avoid some implementational problems of the former systems. However, this scheme can only be eecient if the translation produces short output with a small number of combinators, in order to reduce the time and transient storage space spent during reduction of combinatory terms. In this paper we present a combinatory system an...

متن کامل

Efficient Bracket Abstraction Using Iconic Representations for Combinators

Some fundamental properties of a new uni-variate bracket abstraction algorithm employing a string representation for combinators are established. In particular, if the input term has length n, where n > 1, the algorithm is called fewer than n times to produce the abstract. Furthermore, the space required to store the abstract, in the worst case, is of the order O(n). This algorithm also has a n...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2007